<?php include "config/mysql.php";?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>layout后台布局 - Layui</title>
<link rel="stylesheet" href="../layui/css/layui.css">
<link rel="stylesheet" href="../css/admin.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <?php include "public/header.php";?>
  </div>
  <div class="layui-side layui-bg-black">
    <?php
       include "public/left.php";
    ?>
  </div>
  <div class="layui-body">
  <table class="table table-hover" id="list">
                <!--     <tr>
                       <th>全选</th>
                       <th>删除</th>
                    </tr> -->
                    <!-- <tr>
                       <td><input type="checkbox"  value="" id="checkbox_1" /></td>
                    </tr> -->
                    <tr>
                        <th width="145">选择</th>
                        <th width="145">ID</th>
                        <th width="120">类名</th>
                      
                        <th >类描述</th>
                      
                        <th width="220">操作</th>
                    </tr>

                  <?php
                    $tr=$pdo->query("select * from article_kind ");
                    $str=$tr->fetchAll(PDO::FETCH_ASSOC);
                    $total=$tr->rowCount();   //获取总记录数;
                    $num=4;             //每页显示的记录数;
                    $url="control_kid.php";          //请求的URL 
                    $cpage=isset($_GET["page"])?$_GET["page"]:1;//当前页  
                    $pagenum=ceil($total/$num);//总页数 
                    $offset=($cpage-1)*$num;//开始去数据的位置  
                    $sql1="select * from article_kind order by id desc limit {$offset},{$num}";
                    $tr1=$pdo->query($sql1);
                    $str1=$tr1->fetchAll(PDO::FETCH_ASSOC);
                    $start=$offset+1;//开始记录页 
                    $end=($cpage==$pagenum)?$total:($cpage*$num);//结束记录页 
                    $next=($cpage==$pagenum)?$pagenum :($cpage+1);//下一页  
                    $prev=($cpage==1)? 1:($cpage-1);//前一页   
                  foreach($str1 as $v){ 
                    ?>
                    <tr>
                        <td><input type="checkbox"  value="<?php echo $v['id']; ?>"  /></td>
                        <td><?php echo $v["id"] ?></td>
                        <td><?php echo $v["king"] ?></td>
                        
                        <td><?php echo $v["explanation"] ?></td>                       
                        <td><a href="changekid.php?id=<?php echo $v['id']; ?>">修改</a> <a class="button border-yellow button-little" href="do/do_delekid.php?id=<?php echo $v['id']; ?>" onclick="{
                                    if (confirm('确认删除?删除后整个分类下面的文章将全部删除.')) {
                                        return true;
                                    }
                                    return false;
                                }">删除</a></td>
                      </tr>
                    <?php
                       
                       }
                  ?>
                </table>
                 <table class="table-page">
                 <tr>  
                  <th>共<?php echo $total ?> 条记录</th>
                  <th>当前为第&nbsp<span style="color:red"><?php echo $cpage?></span>/<?php echo $pagenum ?>&nbsp页</th>
                  <th>
                    <?php if($cpage==1){
                      echo "首页";
                    }else{
                      echo "<a href='{$url}?page=1'>首页</a>";
                    }
                    ?>
                  </th>
                  <th><?php  echo "<a href='{$url}?page={$next}'>下一页</a>"?></th>
                  <th><?php  echo "<a href='{$url}?page={$prev}'>上一页</a>"?></th>
                  <th><?php 
                  if($cpage==$pagenum) {
                    echo "尾页";
                  }else{
                  echo "<a href='{$url}?page={$pagenum}'>尾页</a>";
                   }
                   ?>
                   </th>                 
                 </tr>
                </table>
  </div>
 </div>
<script src="../layui/layui.js"></script>
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form()
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');
 
  

  })



</script>
</body>
</html>